package com.iteaj.iboot.plugin.crawler.sites;

import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
@Setter
public class SiteResolverManager {

    private static Map<String, SiteResolver> resolvers = new HashMap<>();

    protected SiteResolverManager(List<SiteResolver> resolvers) {
        if(resolvers != null) {
            resolvers.forEach(SiteResolverManager::registerResolver);
        }
    }

    public static SiteResolver get(String alias) {
        return resolvers.get(alias);
    }

    public static void registerResolver(SiteResolver resolver) {
        resolvers.put(resolver.getAlias(), resolver);
    }
}
